﻿using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace SimpleORM
{
    public class Serializer
    {
        public static byte[] SerializeToBytes(object obj)
        {
            if (obj == null)
                return null;

            using (MemoryStream stream = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(stream, obj);
                return stream.ToArray();
            }
        }
    }
}
